using Zhaoxi.Zhihu.Core.AppUserAggregate.Entites;
using Zhaoxi.Zhihu.Core.AppUserAggregate.Interfaces;
using Zhaoxi.Zhihu.Core.QuestionAggregate.Entites;
using Zhaoxi.Zhihu.Core.QuestionAggregate.Specifications;
using Zhaoxi.Zhihu.SharedKerel.Repositoy;
using Zhaoxi.Zhihu.SharedKerel.Result;

namespace Zhaoxi.Zhihu.Core.AppUserAggregate.Service;

public class AppUserService(IReadRepository<AppUser> appUsers,IReadRepository<Question> questions) : IAppUserService
{


    public async Task<Result> FollowQuestionAsync(AppUser appuser, int questionId, CancellationToken cancellationToken)
    {
        if (await questions.CountAsync(new QuestionByIdSpec(questionId), cancellationToken) == 0)
        {
            return Result.NotFound("关注问题不存在");
        }
        
        return (Result)appuser.AddFollowQuestion(questionId);
    }

    public Task<Result> FolloweeUserAsync(AppUser appuser, int foloweeId, CancellationToken cancellationToken)
    {
        throw new NotImplementedException();
    }
}